package j04zuoye;

import java.util.Random;

/*
3，三维数组最值
创建一个3层3行5列的三维数组，每个元素是[10, 80]之间的随机数，找出数组中的最大值，
以及最大值元素的下标。

{
  {
    {11,22,44,55}，
    {11,22,44,55}，
    {11,22,44,55}
  },
  {
    {11,22,44,55}，
  }
}

 */
public class J03max3 {
    public static void main(String[] args) {
        Random r = new Random();
        int[][][] arr = new int[3][3][5];
        int max = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                for (int k = 0; k < arr[i][j].length; k++) {
                    arr[i][j][k] = r.nextInt(80-10+1)+10;
                    System.out.print(arr[i][j][k]+" ");
                    if(arr[i][j][k]>max){
                        //更新max
                        max = arr[i][j][k];
                    }
                }
                System.out.println();
            }
            System.out.println("=====");
        }
        //找到max
        System.out.println("max = " + max);
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                for (int k = 0; k < arr[i][j].length; k++) {
                    if(arr[i][j][k]==max){
                        //更新max
                        System.out.println("找到了："+i+","+j+","+k);
                    }
                }
            }
        }
    }
}
